'use strict';

module.exports = app => {
  const {
    INTEGER,
    STRING,
    DATE,
    TEXT,
  } = app.Sequelize;
  const Productevaluate = app.model.define('productevaluate', {
    id: {
      type: INTEGER,
      allowNull: false,
      primaryKey: true,
      autoIncrement: true,
      comment: '序号',
    },
    sid: {
      type: INTEGER,
      comment: '所属商品',
    },
    evaluatename: {
      type: STRING,
      comment: '评价用户名',
    },
    evaluatetext: {
      type: TEXT,
      comment: '评价内容',
    },
    evaluateimg: {
      type: TEXT,
      comment: '评价图片',
    },
    createdDate: {
      type: DATE,
      comment: '创建类型时间',
      field: 'createdDate',
    },
  }, {
    freezeTableName: true,
    timestamps: false, // 去除createAt updateAt
  });
  Productevaluate.associate = function() {
    app.model.Productevaluate.belongsTo(app.model.Productinfo, {
      foreignKey: 'sid',
      targetKey: 'id',
    });
  };
  return Productevaluate;
};
